package org.apache.osgimaker.analyse.algorithm.graph;

/**
 *  A subclass of {@link Vertex} with the following additional properties:
 *  <ul><li>A flag indicating whether this vertex belongs to the graph or not.
 *      <li>The order of visiting.
 *      <li>The low function.
 *  </ul>
 *  The last two properties are used in Tarjan's algorithm to find the
 *  strong components (see {@link StrongComponentProcessor}).
 *
 */
public class AtomicVertex extends Vertex {
  private boolean _graphVertexDefaultValue = true;
  private boolean _graphVertex;
  private int _order;
  private int _low;

  /** Creates an instance for the specified attributes. */
  public AtomicVertex(Attributes attributes) {
    super(attributes);
  }

  /**
   * Reset this instance. That is, it becomes a unvisited vertex
   * where <tt>order = low = -1</tt>. Whether it is a graph vertex or not
   * depends on the default value defined by the method 
   * {@link #setDefaultValueOfGraphVertexFlag}.
   */
  public void reset() {
    super.reset();
    _graphVertex = _graphVertexDefaultValue;
    _order = -1;
    _low = -1;
  }

  /** Returns <tt>true</tt> if this vertex belongs to a graph. */
  public boolean isGraphVertex() {
    return _graphVertex;
  }

  /**
   * Sets the default value of graphVertex flag.
   * @see #reset()
   */  
  public void setDefaultValueOfGraphVertexFlag(boolean flag) {
    _graphVertexDefaultValue = flag;
  }

  /** Returns the order of visiting. */
  public int getOrder() {
    return _order;
  }

  /** Sets the order of visiting. */
  public void setOrder(int order) {
    _order = order;
  }

  /** Returns the current value of the low function. */
  public int getLow() {
    return _low;
  }

  /** Sets the current value of the low function. */
  public void setLow(int low) {
    _low = low;
  }
} //class